home *** CD-ROM | disk | FTP | other *** search
/ AMIGA-CD 2 / Amiga-CD - Volume 2.iso / ungepackte_daten / 1992 / 09 / 2 / window-machine / wm_source.ampk / WM_Source3.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-01  |  8.4 KB  |  541 lines

  1. #include <WM.h>
  2. #include <MS.h>
  3. #include <MyStructs.h>
  4.  
  5. extern struct IntuiText RText[],AText[];
  6.  
  7. USHORT RequestSource()
  8. {
  9.     helpR=helpW->FirstRequest;
  10.     if(CodeArt==0)
  11.     {
  12.         if(ExtraReq()) return(1);
  13.     }
  14.     if((Erlaubt & 8)==0)
  15.     {
  16.         if(CodeArt)
  17.         {
  18.             if(ExtraReq()) return(1);
  19.         }
  20.         return(0);
  21.     }
  22.     if(helpR->Type==1)
  23.     {
  24.         if(SysReqSource()) return(1);
  25.         return(0);
  26.     }
  27.     if(helpR->Type==2)
  28.     {
  29.         if(AlertSource()) return(1);
  30.         return(0);
  31.     }
  32.     RQ++;
  33.     StrEnd=0;
  34.     if(CodeArt==0) sprintf(Buffer,"%s%s ",STR,String[20]);
  35.     MakeName(helpW->Title,RQ,20);
  36.     if(CStart()) return(1);
  37.     if(Null(1)) return(1);
  38.     if(WindowPos()) return(1);
  39.     if(Word(helpR->RelLeft,helpR->RelTop)) return(1);
  40.     if(GadgetZeiger()) return(1);
  41.     if(helpR->ReqImage==NULL)
  42.     {
  43.         if(helpR->ReqBorder)
  44.         {
  45.             AssT(2);
  46.             KUnd();
  47.             InLeer(9,GB);
  48.             if(BuffKom()) return(1);
  49.         }
  50.         else if(Null(1)) return(1);
  51.         if(TextZeiger(helpW->FirstText)) return(1);
  52.     }
  53.     else
  54.     {
  55.         if(Null(1)) return(1);
  56.         if(Null(1)) return(1);
  57.     }
  58.     AssT(1);
  59.     j=0;
  60.     if(helpR->PFlags & POINTREL)
  61.     {
  62.         InBuff(RText[2].IText);
  63.         j++;
  64.     }
  65.     if(helpR->PFlags & NOISYREQ)
  66.     {
  67.         Plus();
  68.         InBuff(RText[3].IText);
  69.     }
  70.     if(helpR->ReqImage)
  71.     {
  72.         Plus();
  73.         InBuff("PREDRAWN");
  74.     }
  75.     if(j==0) Nuller(0);
  76.     if(KomTab()) return(1);
  77.     AssT(0);
  78.     sprintf(LEER,"%d",helpR->BackFill);
  79.     BuffLeer();
  80.     KommaNull(0);
  81.     if(KomTab()) return(1);
  82.     if(helpR->ReqImage)
  83.     {
  84.         if(Null(1)) return(1);
  85.         if(CodeArt)
  86.         {
  87.             sprintf(LEER,"ds.b%s32",ZCode[1]);
  88.             if(BuffKom()) return(1);
  89.         }
  90.         else
  91.         {
  92.             Nuller(15);
  93.             StrEnd=1;
  94.             if(KomTab()) return(1);
  95.             StrEnd=0;
  96.             Nuller(15);
  97.             if(KomTab()) return(1);
  98.         }
  99.         AssT(2);
  100.         i=BM;
  101.         KUnd();
  102.         if(CodeArt) i++;
  103.         InLeer(21,i);
  104.         BuffLeer();
  105.         if(LSave()) return(1);
  106.     }
  107.     else if(Null(0)) return(1);
  108.     if(CodeArt)
  109.     {
  110.         if(LSave()) return(1);
  111.         if(ExtraReq()) return(1);
  112.     }
  113.     else
  114.     {
  115.         CEnde();
  116.         if(DSave()) return(1);
  117.     }
  118.     return(0);
  119. }
  120.  
  121. VOID InBuff(UBYTE *s)
  122. {
  123.     strcat(Buffer,s);
  124. }
  125.  
  126. VOID KommaNull(UBYTE mode)
  127. {
  128.     if(CodeArt)
  129.     {
  130.         InBuff(",0");
  131.         if(mode & 1) Tab();
  132.         if(mode & 2) InBuff(AType[3]);
  133.     }
  134. }
  135.  
  136. USHORT WindowPos()
  137. {
  138.     if(Word(helpW->LeftEdge,helpW->TopEdge)) return(1);
  139.     if(Word(helpW->Width,helpW->Height)) return(1);
  140.     return(0);
  141. }
  142.  
  143. USHORT SysReqSource()
  144. {
  145.     RSQ++;
  146.     if(CodeArt)
  147.     {
  148.         if(ExtraReq()) return(1);
  149.     }
  150.     StrEnd=0;
  151.     if(CodeArt) EquString(String[1],2);        /* Window */
  152.     else
  153.     {
  154.         InBuff(String[6]);    /* define */
  155.         MakeName(helpW->FirstGadget->Name,RSQ,24);
  156.         InBuff(" ");
  157.     }
  158.     SetNull();
  159.     Komma();
  160.     if(CodeArt)
  161.     {
  162.         LineFeed();
  163.         EquString(RqText6.IText,2);
  164.     }
  165.     if(BT==0) SetNull();
  166.     else
  167.     {
  168.         KUnd();
  169.         sprintf(LEER,"I%s%d",String[4],BT);    /* BodyText */
  170.         BuffLeer();
  171.     }
  172.     Komma();
  173.     if(Save()) return(1);
  174.     if(CodeArt)
  175.     {
  176.         LineFeed();
  177.         EquString("PosText",2);
  178.     }
  179.     if(PT==0) SetNull();
  180.     else
  181.     {
  182.         KUnd();
  183.         sprintf(LEER,"I%s%d",String[4],PT);    /* PositiveText */
  184.         BuffLeer();
  185.     }
  186.     Komma();
  187.     if(Save()) return(1);
  188.     if(CodeArt)
  189.     {
  190.         LineFeed();
  191.         EquString("NegText",2);
  192.     }
  193.     KUnd();
  194.     sprintf(LEER,"I%s%d",String[4],NT);    /* NegativeText */
  195.     BuffLeer();
  196.     Komma();
  197.     if(Save()) return(1);
  198.     if(CodeArt)
  199.     {
  200.         LineFeed();
  201.         EquString("PosFlags",2);
  202.     }
  203.     j=0;
  204.     if(helpR->PFlags)
  205.     {
  206.         for(i=0; i<23; i++)
  207.         {
  208.             if(helpR->PFlags & WIDCMP[i]) PIDCMP();
  209.         }
  210.     }
  211.     if(j==0) SetNull();
  212.     Komma();
  213.     if(CodeArt)
  214.     {
  215.         LineFeed();
  216.         EquString("NegFlags",2);
  217.     }
  218.     j=0;
  219.     if(helpR->NFlags)
  220.     {
  221.         for(i=0; i<23; i++)
  222.         {
  223.             if(helpR->NFlags & WIDCMP[i]) PIDCMP();
  224.         }
  225.     }
  226.     if(j==0) SetNull();
  227.     Komma();
  228.     if(CodeArt)
  229.     {
  230.         LineFeed();
  231.         EquString("Width",1);
  232.     }
  233.     sprintf(LEER,"%d",awin->Width);
  234.     BuffLeer();
  235.     Komma();
  236.     if(CodeArt)
  237.     {
  238.         LineFeed();
  239.         EquString("Height",1);
  240.     }
  241.     sprintf(LEER,"%d",awin->Height);
  242.     BuffLeer();
  243.     StrEnd=1;
  244.     if(DSave()) return(1);
  245.     return(0);
  246. }
  247.  
  248. VOID InLeer(UBYTE s,USHORT n)
  249. {
  250.     sprintf(LEER,"%s%d",String[s],n);
  251. }
  252. VOID PIDCMP()
  253. {
  254.     Plus();
  255.     InBuff(WIDCMP1[i]);
  256. }
  257. VOID EquString(UBYTE *s,UBYTE type)
  258. {
  259.     MakeName(helpW->FirstGadget->Name,RSQ,24);
  260.     InBuff(s);
  261.     InBuff(":");
  262.     HTab();
  263.     AssT(type);
  264.     HTab();
  265. }
  266.  
  267. USHORT AlertSource()
  268. {
  269.     AL++;
  270.     StrEnd=1;
  271.     if(CodeArt==0) InBuff(CType[3]);
  272.     MakeName(helpW->Title,AL,23);
  273.     InBuff(String[4]);
  274.     if(CodeArt==0) InBuff(" []");
  275.     if(CStart()) return(1);
  276.     AssT(0);
  277.     helpT=helpW->FirstText;
  278.     while(helpT)
  279.     {
  280.         sprintf(LEER,"%d,%d,%d",helpT->LeftEdge & 0xFF00,
  281.             helpT->LeftEdge & 0x00FF,helpT->TopEdge);
  282.         if(BuffKom()) return(1);
  283.         PL=0;
  284.         AssT(0);
  285.         SetByte(helpT->IText);
  286.         helpT=helpT->NextText;
  287.         if(KomTab()) return(1);
  288.         AssT(0);
  289.         if(CodeArt)
  290.         {
  291.             Nuller(0);
  292.             SetKomma();
  293.         }
  294.         if(helpT) InBuff("1,");
  295.         else Nuller(0);
  296.         if(Save()) return(1);
  297.     }
  298.     LineFeed();
  299.     if(CodeArt==0) CEnde();
  300.     else
  301.     {
  302.         HTab();
  303.         AssT(3);
  304.     }
  305.     DoubleFeed();
  306.     if(CodeArt==0) InBuff(String[6]);
  307.     MakeName(helpW->Title,AL,23);
  308.     if(CodeArt)
  309.     {
  310.         InBuff("Flag:");
  311.         HTab();
  312.         AssT(2);
  313.     }
  314.     else InBuff(" ");
  315.     if(helpR->PFlags) InBuff(AText[2].IText);
  316.     else InBuff(AText[1].IText);
  317.     if(CodeArt) LineFeed();
  318.     else SetKomma();
  319.     MakeName(helpW->Title,AL,23);
  320.     if(CodeArt)
  321.     {
  322.         InBuff("Height:");
  323.         HTab();
  324.         AssT(1);
  325.     }
  326.     else
  327.     {
  328.         InBuff(String[4]);
  329.         SetKomma();
  330.     }
  331.     sprintf(LEER,"%d",helpW->Height);
  332.     BuffLeer();
  333.     if(DSave()) return(1);
  334.     return(0);
  335. }
  336.  
  337. VOID SetKomma()
  338. {
  339.     InBuff(",");
  340. }
  341.  
  342. VOID SetByte(UBYTE *s)
  343. {
  344.     UBYTE z=2;
  345.     if(CodeArt) z++;
  346.     InBuff(ZCode[z]);
  347.     InBuff(s);
  348.     InBuff(ZCode[z]);
  349. }
  350.  
  351. USHORT BuffKom()
  352. {
  353.     BuffLeer();
  354.     if(KomTab()) return(1);
  355.     return(0);
  356. }
  357.  
  358. USHORT ExtraReq()
  359. {
  360.     if(helpR->Type==1)
  361.     {
  362.         helpG=helpW->FirstGadget;
  363.         if(CodeArt) NT=TX+1;
  364.         if(TextSource(helpG->FirstText,0)==1) return(1);
  365.         if(CodeArt==0) NT=TX;
  366.         PT=0;
  367.         if(helpG->NextGadget->PFlags)
  368.         {
  369.             if(CodeArt) PT=TX+1;
  370.             if(TextSource(helpG->NextGadget->FirstText,0)==1)
  371.                 return(1);
  372.             if(CodeArt==0) PT=TX;
  373.         }
  374.     }
  375.     BT=0;
  376.     if(helpW->FirstText && helpR->Type < 2)
  377.     {
  378.         if(helpR->ReqImage==NULL)
  379.         {
  380.             TXL++;
  381.             i=1;
  382.             if(helpR->Type==1) i--;
  383.             if(CodeArt) BT=TX+1;
  384.             if(TextSource(helpW->FirstText,i)==1) return(1);
  385.             if(CodeArt==0)
  386.             {
  387.                 BT=TX;
  388.                 sprintf(Buffer,"%s%s%s%d I%s%d",String[6],
  389.                     String[4],String[5],TXL,String[4],TX);
  390.                 if(DSave()) return(1);
  391.             }
  392.         }
  393.     }
  394.     if(helpW->FirstGadget && helpR->Type==0)
  395.     {
  396.         helpG=helpW->FirstGadget;
  397.         if(GadgetSource()) return(1);
  398.     }
  399.     if(helpR->ReqBorder != NULL && helpR->ReqImage==NULL)
  400.     {
  401.         BType=2;
  402.         if(BorderSource(0)) return(1);
  403.         GB=BO;
  404.     }
  405.     if(helpR->ReqImage)
  406.     {
  407.         if(BitMapSource()) return(1);
  408.     }
  409.     return(0);
  410. }
  411.  
  412. USHORT BitMapSource()
  413. {
  414.     BM++;
  415.     helpI=helpR->ReqImage;
  416.     if(CodeArt==0)
  417.     {
  418.         if(DataSource(1)) return(1);
  419.         sprintf(Buffer,"%s%s ",STR,String[21]);
  420.     }
  421.     InLeer(21,BM);
  422.     BuffLeer();
  423.     StrEnd=0;
  424.     if(CStart()) return(1);
  425.     Iffx=((helpI->Width+15) >> 4) << 1;
  426.     if(Word(Iffx,helpI->Height)) return(1);
  427.     if(Byte(0,helpI->Depth)) return(1);
  428.     AssT(1);
  429.     Nuller(0);
  430.     StrEnd=1;
  431.     if(KomTab()) return(1);
  432.     StrEnd=0;
  433.     for(PL=0; PL < helpI->Depth; PL++)
  434.     {
  435.         AssT(2);
  436.         if(CodeArt==0) InBuff("(PLANEPTR)");
  437.         sprintf(LEER,"%s%d%s%d",String[21],BM,String[22],PL+1);
  438.         BuffLeer();
  439.         if((PL+1) != helpI->Depth)
  440.         {
  441.             if(KomTab()) return(1);
  442.         }
  443.     }
  444.     if(CodeArt==0)
  445.     {
  446.         LineFeed();
  447.         CEnde();
  448.     }
  449.     if(DSave()) return(1);
  450.     if(CodeArt) if(DataSource(1)) return(1);
  451.     return(0);
  452. }
  453.  
  454. VOID Nuller(UBYTE anzahl)
  455. {
  456.     while(anzahl)
  457.     {
  458.         InBuff("0,");
  459.         anzahl--;
  460.     }
  461.     InBuff("0");
  462. }
  463.  
  464. USHORT TextZeiger(struct MyText *text)
  465. {
  466.     if(text)
  467.     {
  468.         AssT(2);
  469.         i=TX;
  470.         KUnd();
  471.         if(CodeArt) i++;
  472.         sprintf(LEER,"I%s%d",String[4],i);
  473.         if(BuffKom()) return(1);
  474.     }
  475.     else if(Null(1)) return(1);
  476.     return(0);
  477. }
  478.  
  479. USHORT GadgetZeiger()
  480. {
  481.     if(helpW->FirstGadget && (Erlaubt & 32))
  482.     {
  483.         helpG=helpW->FirstGadget;
  484.         while(helpG->Border==2 || helpG->Image==2)
  485.             helpG=helpG->NextGadget;
  486.         if(helpG)
  487.         {
  488.             AssT(2);
  489.             KUnd();
  490.             if(strlen(helpG->Name))
  491.                 InBuff(helpG->Name);
  492.             else
  493.             {
  494.                 i=GD;
  495.                 if(CodeArt) i++;
  496.                 InLeer(8,i);
  497.                 BuffLeer();
  498.             }
  499.             if(KomTab()) return(1);
  500.         }
  501.         else if(Null(1)) return(1);
  502.     }
  503.     else if(Null(1)) return(1);
  504.     return(0);
  505. }
  506.  
  507. VOID WinBorder(struct Window *w)
  508. {
  509.     WV1[2]=w->Width-11;
  510.     WV1[4]=w->Width-11;
  511.     WV1[5]=w->Height-5;
  512.     WV1[7]=w->Height-5;
  513.     WV2[2]=w->Width-9;
  514.     WV2[4]=w->Width-9;
  515.     WV2[5]=w->Height-5;
  516.     WV2[7]=w->Height-5;
  517.     WV3[2]=w->Width-7;
  518.     WV3[4]=w->Width-7;
  519.     WV3[5]=w->Height-3;
  520.     WV3[7]=w->Height-3;
  521.     WV4[2]=w->Width-5;
  522.     WV4[4]=w->Width-5;
  523.     WV4[5]=w->Height-3;
  524.     WV4[7]=w->Height-3;
  525.     WV5[2]=w->Width-3;
  526.     WV5[4]=w->Width-3;
  527.     WV5[5]=w->Height-1;
  528.     WV5[7]=w->Height-1;
  529.     WV6[2]=w->Width-1;
  530.     WV6[4]=w->Width-1;
  531.     WV6[5]=w->Height-1;
  532.     WV6[7]=w->Height-1;
  533.     DrawBorder(w->RPort,&WB[5],0,0);
  534. }
  535.  
  536. USHORT TestReqImage(struct MyWindow *w)
  537. {
  538.     if(w->FirstRequest == NULL || (w->FirstRequest != NULL &&
  539.         w->FirstRequest->ReqImage==NULL)) return(1);
  540.     return(0);
  541. }